{extend name="admin/b2c/base" /}
{block name="resources"/}
<style>
.style0list table input{
	color:#666;
	width:206px;
	margin-bottom: 0px;
	border: 1px solid #ccc;
}
.style0list table input.sort{
	width: auto;
	text-align: center;
}
.style0list tbody td {
	line-height:28px;
}
</style>
{/block}
{block name="right_tab"}
<li><a class="nscs-table-handle_green" href="ADMIN_MAIN/Goods/addGoodsGroup.html"><i class="fa fa-plus-circle"></i>&nbsp;添加商品分组</a></li>
{/block}
{block name="main"}
<div class="mod-table">
	<div class="mod-table-head">
		<div class="con style0list">
			<table>
				<colgroup>
					<col style="width: 1%;">
					<col style="width: 5%;">
					<col style="width: 5%;">
					<col style="width: 50%;">
					<col style="width: 10%;">
					<col style="width: 10%;">
				</colgroup>
				<thead>
					<tr align="center">
						<th></th>
						<th>排序</th>
						<th></th>
						<th style="text-align: left;">商品分组</th>
						<th>是否显示</th>
						<th>操作</th>
					</tr>
				</thead>
				<colgroup>
					<col style="width: 1%;">
					<col style="width: 5%;">
					<col style="width: 5%;">
					<col style="width: 50%;">
					<col style="width: 10%;">
					<col style="width: 10%;">
				</colgroup>
				<tbody>
					{foreach name="group_list" item="v1"}
						<tr class="pid_0" style="height: 30px;">
							<td>{if condition="$v1['child_list'] neq array()"}<a
								href="javascript:;"
								onclick="tab_switch({$v1['group_id']})"
								class="tab_jia_{$v1['group_id']}"
								style="display: block;"><i class="fa fa-plus-circle"></i></a><a href="javascript:;"
								onclick="tab_switch({$v1['group_id']})"
								class="tab_jian_{$v1['group_id']}"
								style="display: none;"><i class="fa fa-minus-circle"></i></a> {/if}
							</td>
							<td style="text-align: center;"><input type="text" class="sort" fieldid="{$v1['group_id']}" fieldname="sort" value="{$v1['sort']}" size="1"></td>
							<td style="text-align: center;">
								{if condition="$v1['picture']['pic_cover'] neq ''"}
									<img src="__ROOT__/{$v1['picture']['pic_cover']}" style="height:30px;">
									
								{else /} 
									<img src="__STATIC__/images/left_agent_commission.png" style="height:30px;">
								{/if}
							
							</td>
							<td><input type="text" fieldid="{$v1['group_id']}" fieldname="group_name" value="{$v1['group_name']}"></td>
							<td style="text-align: center;">{$v1['is_visible'] ? '是' : '否'}</td>
							<td style="text-align: center;"><a
							href="ADMIN_MAIN/Goods/updateGoodsGroup.html?group_id={$v1['group_id']}">修改</a>
							<a href="javascript:void(0);"
							onclick="delGroup({$v1['group_id']})">删除</a></td>
						</tr>
						{foreach name="v1['child_list']" item="v2"}
						<tr class="pid_{$v1['group_id']}" style="height: 30px;display: none;">
							<td></td>
							<td style="text-align: center;"><input type="text" class="sort" fieldid="{$v2['group_id']}" fieldname="sort" value="{$v2['sort']}" size="1"></td>
							<td style="text-align: center;">
								{if condition="$v2['picture']['pic_cover'] neq ''"}
									<img src="__ROOT__/{$v2['picture']['pic_cover']}" style="height:30px;">
								{else /} 
									<img src="__STATIC__/images/left_agent_commission.png" style="height:30px;">
								{/if}
							<!-- <img src="__ROOT__/{$v2['picture']['pic_cover']}" style="height:30px;"> -->
							</td>
							<td><span style="color:#ccc;">|——</span> <input type="text" fieldid="{$v2['group_id']}" fieldname="group_name" value="{$v2['group_name']}"></td>
							<td style="text-align: center;">{$v2['is_visible'] ? '是' : '否'}</td>
							<td style="text-align: center;"><a
							href="ADMIN_MAIN/Goods/updateGoodsGroup.html?group_id={$v2['group_id']}">修改</a>
							<a href="javascript:void(0);"
							onclick="delGroup({$v2['group_id']})">删除</a></td>
						</tr>
						{/foreach} {/foreach}
				</tbody>
			</table>
		</div>
	</div>
</div>
<style>
</style>
<script type="text/javascript">
$(".style0list table input").change(function(){
	var fieldid = $(this).attr('fieldid');
	var fieldname = $(this).attr('fieldname');
	var fieldvalue = $(this).val();
	$.ajax({
		type:"post",
		url:"ADMIN_MAIN/Goods/modifyGoodsGroupField",
		data:{'fieldid':fieldid,'fieldname':fieldname,'fieldvalue':fieldvalue},
		async:true,
		success: function (data) {
		}
	});
});
	function tab_switch(module_id){
		if($(".pid_"+module_id).css('display') != 'none'){
			$(".tab_jian_"+module_id).hide();
			$(".tab_jia_"+module_id).show();
			$(".pid_"+module_id).hide(300);
		}else{
			$(".tab_jian_"+module_id).show();
			$(".tab_jia_"+module_id).hide();
			$(".pid_"+module_id).show(500);
		}
	}
	/* 删除分类 */
	function delGroup(group_id){
		$( "#dialog" ).dialog({
            buttons: {
                "确定": function() {
                    $(this).dialog('close');
					$.ajax({
						type:"post",
						url:"ADMIN_MAIN/Goods/deleteGoodsGroup",
						data:{'group_id':group_id},
						async:true,
						dataType : "json",
						success:function (data) {
							if(data['code'] > 0){
								showMessage('success', data["message"],'ADMIN_MAIN/Goods/goodsGroupList');
							}else{
								showMessage('error', data["message"]);
							}
						}
					});
                },
    			"取消,#e57373":function(){
    				$(this).dialog('close');
    			}
            },
            contentText:"你确定删除吗？",
            title:"消息提醒"
        });
	}

</script>
{include file="admin/b2c/openDialog" /}
{/block}